/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.comfacauca.xmlc2.dao;

import com.comfacauca.xmlc2.entidades.glpi.GlpiTickettasks;
import com.comfacauca.xmlc2.servicio.TicketI;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author eorozco
 */



public class TicketDAO implements TicketI{

    private static final String PERSISTENCE_UNIT_NAME = "glpiPU";
    private static EntityManagerFactory factory;
    
    
    @Override
    public void setTiempoTicket(GlpiTickettasks tickettasks) {
        factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
        EntityManager em = factory.createEntityManager();
        try {
        
        em.getTransaction().begin();
        em.merge(tickettasks);
        em.getTransaction().commit();
        
       
        } catch (SecurityException ex) {
            Logger.getLogger(ProyectosDAO.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalStateException ex) {
            Logger.getLogger(ProyectosDAO.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            //close the em to release any resources held up by the persistebce provider
            if(em != null) {
                em.close();
            }
        }    
            
    }
    
    
    
}
